package leetcode;

public class LeetCode101 {

    //数的解法相对单一  1.递归 2.层次遍历 用一个队列(先进先出)
    //对称其实 就是比较两棵树 没必要在一颗数上比较，需要判断数为不为空
    public boolean isSymmetric(TreeNode root) {
        //先比较树为不为空
        return judge(root, root);
    }

    public boolean judge(TreeNode left, TreeNode right) {
        if (left == null && right == null)
            return true;
        if (left == null || right == null) {
            return false;
        }
        if (left.val != right.val) {
            return false;
        }
        return (left.val == right.val)
                && judge(left.right, right.left)
                && judge(left.left, right.right);
    }
//------------------------------------------------------------------
}
